<script type="text/javascript" >
    jQuery(document).ready(function(){
        jQuery(".gallery1 a[rel^='prettyPhoto']").prettyPhoto({
            theme:'facebook',
            keyboard_shortcuts: false
        });
        
        jQuery('#filter_cat').change(function(){
            var action = 'showUserCard';
            var data = new Array();
            data['category_id'] = jQuery(this).val(); 
            data['user_id'] = "<?php echo $current_user_id?>"; 
            stFacebookToolbox.loadPage(action, data);              
        });
        
        stFacebookToolbox.pagingCallbackFunction = function(data){
            data['user_id'] = "<?php echo $current_user_id?>"; 
            data['category_id'] = jQuery('#filter_cat').val();
        };

        stFacebookToolbox.sortCallbackFunction = function(data){
            data['user_id'] = "<?php echo $current_user_id?>"; 
            data['category_id'] = jQuery('#filter_cat').val();
        }
    });
</script>
<div class="w100p bgl">
    <div class="w100p bgr">
        <div class="inner_container">
            <?php echo $functions->appPostcardMenu();?>
            <div class="filter float_right" style="margin: 5px 15px 5px 5px" >
                <label>Filter:</label>
                <select class="required" id="filter_cat">
                    <option value="">Show All</option>
                    <?php
                    foreach ($categories as $value) {
                        if($current_category_id == $value->id){
                            $cur = "selected";
                        }else{
                            $cur = "";
                        }
                        echo "<option {$cur} value='{$value->id}'>{$value->title}</option>";
                    }
                    ?>
                </select>
            </div>
            
            <div id="" class="postcardBlock gallery1">
                
                    <table class="widefat " cellspacing="0">
                        <thead>
                            <tr>
                                <?php print_column_headers('stFacebookToolbox_stPostcards'); ?>
                            </tr>
                        </thead>

                        <tbody>
                            <?php
                            if (count($objects) > 0) {
                                $tr_class = "";
                                $uploadDir = wp_upload_dir();
                                foreach ($objects as $value) {
                                    $time = explode(' ', $value->cdate);
                                    $date = explode('-', $time[0]);
                                    $date = $date[2].'.'.$date[1].'.'.$date[0];
                                    $time = $time[1];
                                    
                                    $cdate = $date.' '.$time;
                                    if (empty($tr_class) || $tr_class == "class='bg_gray2'") {
                                        $tr_class = "class='bg_gray1'";
                                    } else {
                                        $tr_class = "class='bg_gray2'";
                                    }
                                    $td_extra = "<td>" . $value->customer_name . "</td>";
                                    
                                    $viewed = empty($value->viewed)? 0:$value->viewed;
                                    $shared_fb = empty($value->shared_fb)? 0:$value->shared_fb;
                                    $shared_email = empty($value->shared_email)? 0:$value->shared_email;
                                    $shared = $shared_fb + $shared_email;
                                    $back_url = "";
                                    if(!empty($value->back_url)){
                                        $back_url = "<a title='' href='{$value->back_url}' rel=\"prettyPhoto\">"
                                        . "<img height='70' src='" . $value->back_thumb_url . "' alt=''>"
                                        . "</a>";
                                    }
                                    $td_extra2 =  "<td>$back_url</td>"
                                    ."<td align='center'> $viewed </td>"       
                                    ."<td align='center'> $shared </td>"
                                    ."<td align='center'> $shared_fb </td>"
                                    ."<td align='center'> $shared_email </td>"       
                                    ;
                                        
                                    $thumb_url = '';
                                    if(!empty($value->thumb_url)){
                                        $thumb_url = "<a title='' href='{$value->url}' rel='prettyPhoto'>"
                                        . "<img height='70' src='" . $value->thumb_url . "' alt=''>"
                                        . "</a>";
                                    }
                                    $back_card_text = stripcslashes($value->back_card_text); 
                                    $description = stripcslashes($value->description);   

                                    echo "<tr $tr_class id='object_{$value->id}' >"
                                    . "<td>" . $value->name
                                    . "<div class=\"row-actions short_action\">"                                    
                                    . "<span class='trash' short_action='delete' id='$value->id' confirm='Are you sure you want to delete this object?'>Trash </span>"
                                    . "</div>"
                                    . "</td>"
                                     . "<td>" . $value->category_title . "</td>"       
                                    . $td_extra
//                                    . "<td>" . $value->file_name . "</td>"
                                    . "<td>"
                                    . $thumb_url                                    
                                    . "</td>"
                                    . $td_extra2
//                                    . "<td>" . $value->photographer . "</td>"
                                    . "<td>" . $cdate . "</td>"
                                    . "</tr>"
                                    ;
                                }
                            }
                            ?>
                        </tbody>
                    </table>
                <div class="page_d">
                    <?php echo $pagination ?>
                    <div class="cl"></div>
                </div>
            </div>
            <br clear="both" />
        </div>
    </div>
</div>